package com.wss.common.view;

import com.wss.common.base.BaseActionBarAbility;
import com.wss.common.base.BaseFragment;
import com.wss.common.base.ResourceTable;
import com.wss.common.base.mvp.BasePresenter;
import com.wss.common.constants.Dic;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Component;
import ohos.agp.components.ComponentContainer;

/**
 * Describe：跳板Activity,主要是跳转一些Fragment
 * 统一采用ARouter方式跳转
 * Created by 吴天强 on 2020/5/7.
 */
public class SpringboardAbility extends BaseActionBarAbility {
    @Override
    protected BasePresenter createPresenter() {
        return null;
    }

    @Override
    protected int getLayoutId() {
        return ResourceTable.Layout_ability_springboard;
    }

    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        initView();
    }

    protected void initView() {
        boolean isActionBar = getIntent().getBooleanParam(Dic.IS_ACTION_BAR, false);
        String titleText = getIntent().getStringParam(Dic.TITLE_TEXT);
        getTitleBar().setVisibility(isActionBar ? Component.VISIBLE : Component.HIDE);
        setCenterText(titleText);
        BaseFragment fragment = getIntent().getSerializableParam(Dic.TARGET_FRAGMENT_PATH);
        ((ComponentContainer)findComponentById(ResourceTable.Id_fl_content))
                .addComponent(fragment.getRootView());
    }
}
